<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:a4j="http://richfaces.org/a4j"
      xmlns:rich="http://richfaces.org/rich"
      xmlns:s="http://jboss.com/products/seam/taglib">
      <body>
       <h:form>
        <a4j:include viewId="toolBar.xhtml"/>
        <table style="width:100%">
            <tr>
                <td style="width:80%" valign="top">
                <rich:datascroller for="returnTypesTable"/>
                <rich:dataTable id="returnTypesTable" var="retType" value="#{returnTypeSession.returnTypes}" rows="20" style="width:100%">
                      <rich:column style="text-align:center" sortBy="#{retType.code}">
                          <f:facet name="header">
                             #{messages['fina2.code']}
                          </f:facet>
                          <h:outputText value="#{retType.code}"/>
                      </rich:column>
                      <rich:column style="text-align:center" sortBy="#{retType.description}">
                          <f:facet name="header">
                              #{messages['fina2.description']}
                          </f:facet>
                          <h:outputText value="#{retType.description}"/>
                      </rich:column>
                      <rich:column style="text-align:center" sortIcon="/images/edit.gif">
                          <f:facet name="header">
                              #{messages['fina2.amend']}
                          </f:facet>
                          <a4j:commandButton image="/images/edit.gif" action="#{returnTypeSession.setSelectedRetType(retType)}" oncomplete="Richfaces.showModalPanel('returnTypeEditPanel')" reRender="returnTypeEdit">
                              <a4j:actionparam name="oldCode" assignTo="#{returnTypeValidator.oldCode}" value="#{retType.code}"/>
                          </a4j:commandButton>
                      </rich:column>
                      <rich:column style="text-align:center" sortIcon="/images/remove.gif">
                          <f:facet name="header">
                              #{messages['fina2.delete']}
                          </f:facet>
                          <a4j:commandButton image="/images/remove.gif" oncomplete="Richfaces.showModalPanel('confirmation')" reRender="removeReturnType">
                              <a4j:actionparam name="retTypeToRemove" assignTo="#{returnTypeSession.code}" value="#{retType.code}"/>
                          </a4j:commandButton>
                      </rich:column>
                </rich:dataTable>
                </td>
           </tr>
        </table> 
       </h:form>
      
       <rich:modalPanel id="confirmation" autosized="true" resizeable="false" width="300" >
           <f:facet name="header">
               #{messages['fina2.web.confirm']}
           </f:facet>
           <f:facet name="controls">
               <h:graphicImage value="../images/close.gif"  onclick="Richfaces.hideModalPanel('confirmation')"/>
           </f:facet>
           <h:form>
               <s:div id="removeReturnType">
                   <table align="center" width="100%" style="font-size:12px">
                       <tr>
                          <td style="font-size:12px">#{messages['fina2.returns.returnTypeDeleteQuestion']}</td>
                       </tr>
                   </table>
              </s:div>
              <rich:spacer height="5px"/>
              <table align="center">
                  <tr>
                      <td>
                          <a4j:commandButton action="#{returnTypeSession.removeReturnType}" value="#{messages['fina2.web.ok']}" style="width:80px" oncomplete="Richfaces.hideModalPanel('confirmation')" reRender="returnTypesTable"/>
                      </td>
                      <td><rich:spacer width="3px"/></td>
                      <td><a4j:commandButton onclick="Richfaces.hideModalPanel('confirmation')" value="#{messages['fina2.web.cancel']}" style="width:80px"/></td>
                  </tr>
             </table>
        </h:form>
       </rich:modalPanel>
      
      <rich:modalPanel id="returnTypePanel" autosized="true" resizable="false" width="470">
          <f:facet name="header">
              #{messages['fina2.create']}
          </f:facet>
          <f:facet name="controls">
              <h:graphicImage value="/images/close.gif" onclick="Richfaces.hideModalPanel('returnTypePanel')"/>
          </f:facet>
          <h:form>
              <f:facet name="beforeInvalidField">
                  <s:message style="font-size:12px;color:red"/>
              </f:facet>
              <f:facet name="aroundInvalidField">
                  
              </f:facet>
              <f:facet name="afterInvalidField">
                  <s:div style="display:block;padding-bottom:12px"/>
              </f:facet>
              <s:div id="returnTypes">
                  <table align="center" width="100%" style="font-size:12px">
                       <tr>
                          <td><rich:spacer width="12px" height="12px"/></td>
                       </tr>
                       <tr>
                           <td>#{messages['fina2.code']}</td>
                           <td><div style="color:red">*</div></td>
                           <td>
                               <s:decorate>
                                  <h:inputText value="#{returnTypeSession.returnType.code}" validator="#{returnTypeValidator.validateCode}" required="true" requiredMessage="#{messages['fina2.bank.pleaseEnterCode']}" style="width:330px"/>
                               </s:decorate>
                           </td>
                      </tr>
                      <tr>
                          <td><rich:spacer width="12px" height="12px"/></td>
                      </tr>
                      <tr>
                          <td>#{messages['fina2.description']}</td>
                          <td><div style="color:red">*</div></td>
                          <td>
                              <s:decorate> 
                                 <h:inputText value="#{returnTypeSession.returnType.description}" validator="#{returnTypeValidator.validateDescription}" required="true" requiredMessage="#{messages['fina2.pleaseEnterDescription']}"  style="width:330px"/>
                              </s:decorate>
                          </td>
                      </tr>
                </table>
                <rich:spacer height="3px"/>
                <table align="center" >
                   <tr>
                       <td><a4j:commandButton reRender="returnTypes"  action="#{returnTypeSession.addReturnType()}" value="#{messages['fina2.web.ok']}" style="width:80px"/></td>
                       <td><rich:spacer width="3px"/></td>
                       <td><a4j:commandButton onclick="Richfaces.hideModalPanel('returnTypePanel');return false;" value="#{messages['fina2.cancel']}" style="width:80px"/></td>
                   </tr>
                </table>
              </s:div>
          </h:form>
      </rich:modalPanel>
      
      <rich:modalPanel id="returnTypeEditPanel" autosized="true" resizeable="false" width="470">
          <f:facet name="header">
              #{messages['fina2.amend']}
          </f:facet>
          <f:facet name="controls">
              <h:graphicImage value="/images/close.gif" onclick="Richfaces.hideModalPanel('returnTypeEditPanel')"/>
          </f:facet>
          <h:form>
              <f:facet name="beforeInvalidField">
                  <s:message style="font-size:12px;color:red"/>
              </f:facet>
              <f:facet name="aroundInvalidField">
              
              </f:facet>
              <f:facet name="afterInvalidField">
                  <s:div style="display:block;padding-bottom:12px"/>
              </f:facet>
              <s:div id="returnTypeEdit">
                  <table align="center" width="100%" style="font-size:12px">
                       <tr>
                          <td><rich:spacer width="12px" height="12px"/></td>
                       </tr>
                       <tr>
                           <td>#{messages['fina2.code']}</td>
                           <td><div style="color:red">*</div></td>
                           <td>
                               <s:decorate>
                                  <h:inputText value="#{returnTypeSession.selectedRetType.code}" validator="#{returnTypeValidator.validateEditCode}" required="true" requiredMessage="#{messages['fina2.bank.pleaseEnterCode']}" style="width:330px"/>
                               </s:decorate>
                           </td>
                      </tr>
                      <tr>
                          <td><rich:spacer width="12px" height="12px"/></td>
                      </tr>
                      <tr>
                          <td>#{messages['fina2.description']}</td>
                          <td><div style="color:red">*</div></td>
                          <td>
                              <s:decorate> 
                                 <h:inputText value="#{returnTypeSession.description}" validator="#{returnTypeValidator.validateDescription}" required="true" requiredMessage="#{messages['fina2.pleaseEnterDescription']}"  style="width:330px"/>
                              </s:decorate>
                          </td>
                      </tr>
                </table>
                <rich:spacer height="3px"/>
                <table align="center" >
                   <tr>
                       <td><a4j:commandButton reRender="returnTypeEdit" data="#{returnTypeSession.success}"  action="#{returnTypeSession.updateReturnType()}" value="#{messages['fina2.web.ok']}" oncomplete="if(data)Richfaces.hideModalPanel('returnTypeEditPanel')" style="width:80px"/></td>
                       <td><rich:spacer width="3px"/></td>
                       <td><a4j:commandButton onclick="Richfaces.hideModalPanel('returnTypeEditPanel');return false;" value="#{messages['fina2.cancel']}" style="width:80px"/></td>
                   </tr>
                </table>
              </s:div>
          </h:form>
      </rich:modalPanel>
      </body>
</html>